<?php

/**
 * Description of API_ConfigManager
 *
 * @author prometheus
 */
class API_ConfigManager
{
	protected static $configs = array();

	public static $apiPath = '';

	public static $systemPath = '';

	public static function get($x10sionName)
	{
		if (isset(self::$configs[$x10sionName]))
		{
			return self::$configs[$x10sionName];
		}
		else
		{
			return NULL;
		}
	}

	public static function init()
	{
		self::$apiPath = str_replace('\\', '/', dirname(x10::getPathForClass('API_ConfigManager'))).'/';
		self::$systemPath = str_replace('\\', '/', dirname(self::$apiPath)).'/';

		$cfgFiles = glob(self::$apiPath.'*.config.json');
		if (is_array($cfgFiles))
		{
			foreach ($cfgFiles as $file)
			{
				$obj = new x10_Util_JSON('file://'.$file);
				$fn = basename($file);
				$regKey = str_replace('.config.json', '', $fn);
				self::$configs[$regKey] = $obj->get();
			}
		}
	}

	public static function done()
	{
		foreach (self::$configs as $k=>$o)
		{
			unset($o);
			unset(self::$configs[$k]);
		}
	}
}

?>